#ifndef LABEL_H
#define LABEL_H

#include <functional>
#include "element.h"

class QLUISHARED_EXPORT Label : public Element
{
    Q_OBJECT

public:
    Label();

    /*********************************************************************
     *                    Copying
     * *******************************************************************/
public:
    virtual bool copyFrom(const Element *e) override;
    virtual Element* clone() const override;

    /*********************************************************************
     *                    Position & Size
     * *******************************************************************/
public:
    virtual QRect sizeHint() const;
    void adjustSize();

    /*********************************************************************
     *                    Content
     * *******************************************************************/
public:
    Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged)

    typedef std::function<QString()> TextBinding;

    void setText(const QString& text);
    QString text() const;
    void bindText(const TextBinding &binding, int width=-1);

signals:
    void textChanged();

private:
    TextBinding text_binding_;


    /*********************************************************************
     *                    paint
     * *******************************************************************/
protected:
    virtual bool prevUpdate() override;
    virtual void paintEvent() override;

};

#endif // LABEL_H
